<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<html>
<head>
<style>
table { 
    display: table;
    border-collapse: separate;
    border-spacing: 2px;
    border-color: gray;
    border-left: 50px;
}
</style>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {	
	$('#saveBtn').click(function() {	
		$.ajax({
			type:"POST",
 			url:"/am/regTest",
			data:$('#submit').serialize(),
			dataType:"json",
			success: function(data) {
				<%-- Do something with data that came back. --%> 
				
				if(data.hostMsg == "incorrectHost"){
					<%-- $('#welcometext').text("기존에 등록되어 있는 host입니다."); --%>
					
					alert("기존에 등록되어 있는 host입니다.");
					document.getElementById("host").focus();
					
				}else if(data.serialMsg == "incorrectSerial"){
					<%-- $('#welcometext').text("기존에 등록되어 있는 serialNo입니다."); --%>
					
					alert("기존에 등록되어 있는 serialNo입니다.");
					document.getElementById("serialNo").focus();
					
				}else if(data.cpuMsg == "incorrectCpu"){
					<%-- $('#welcometext').text("CPU 임계치 설정이 잘못되었습니다."); --%>
					
					alert("CPU 임계치는 Critical > Major > Minor 순으로 지정해야 합니다.");
					document.getElementById("cpuCritical").focus();
					
				}else if(data.memoryMsg == "incorrectMemory"){
					<%-- $('#welcometext').text("Memory 임계치 설정이 잘못되었습니다."); --%>
					
					alert("Memory 임계치는 Critical > Major > Minor 순으로 지정해야 합니다.");
					document.getElementById("memoryCritical").focus();
					
				}else if(data.hddMsg == "incorrectHdd"){
					<%-- $('#welcometext').text("HDD 임계치 설정이 잘못되었습니다."); --%>
					
					alert("HDD 임계치는 Critical > Major > Minor 순으로 지정해야 합니다.");
					document.getElementById("hddCritical").focus();
					
				}else{
					alert('등록이 완료되었습니다.');
					$('#submit').submit();
				}	
			}
		});		
		
	});	
});
			
</script>

</head>
<body>
    			
<h1 align="center">Asset Manager</h1>
	<h2 align="center">서버 기본 정보 및 임계치 설정</h2>
		<div id="welcometext" style="color: red" align="center">
		  
		</div>
		<div align="center">
		<hr align="center" width="500">
		<form id="submit" action="/am/submit" method="post">			
			<table style="left: 50px">
				<tr height="20px">
					<th style="width: 100px">HOST:</th>
					<td>
						<spring:bind path="serverDto.host">					
							<input type="text" style="height: 20px; width: 150px" id="host" name="host" maxlength="40" value="partner.medialog.co.kr">
						</spring:bind>
					</td>
					<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
					<%--<th style="color: red;">CPU Critical:</th> --%>
					<th style="color: red; width: 100px">CPU Critical:</th>
					<td>						
						<spring:bind path="criticalDto.cpuCritical">
							<%-- <input type="text" style="height: 20px; width: 150px" name="cpuCritical"  maxlength="20" value="90"> --%>
							<select name="cpuCritical" id="cpuCritical" style="height: 20px; width: 150px">
								<option value="90" selected="selected">90</option>
								<option value="80">80</option>
								<option value="70">70</option>
								<option value="60">60</option>
								<option value="50">50</option>
								<option value="40">40</option>
								<option value="30">30</option>
								<option value="20">20</option>
								<option value="10">10</option>
								<option value="0">0</option>
							</select>
						</spring:bind>
					</td>
				</tr>
				<tr height="20px">
					<th style="width: 100px">Port_No:</th>
					<td>
						<spring:bind path="serverDto.portNum">					
							<input type="text" style="height: 20px; width: 150px" name="portNum" maxlength="20" value="5012">
						</spring:bind>
					</td>
					<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
					<th style="color: yellow; width: 100px">CPU Major:</th>
					<td>	
						<spring:bind path="criticalDto.cpuMajor">					
							<%-- <input type="text" style="height: 20px; width: 150px" name="cpuMajor"  maxlength="20" value="80"> --%>
							<select name="cpuMajor" style="height: 20px; width: 150px">
								<option value="90">90</option>
								<option value="80">80</option>
								<option value="70" selected="selected">70</option>
								<option value="60">60</option>
								<option value="50">50</option>
								<option value="40">40</option>
								<option value="30">30</option>
								<option value="20">20</option>
								<option value="10">10</option>
								<option value="0">0</option>
							</select>
						</spring:bind>
					</td>
				</tr>
				<tr height="20px">
					<th style="width: 100px">ID:</th>
					<td>
						<spring:bind path="serverDto.svrId">					
							<input type="text" style="height: 20px; width: 150px" name="svrId" maxlength="20" value="freshman">
						</spring:bind>
					</td>
					<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
					<th style="color: lime; width: 100px">CPU Minor:</th>
					<td>	
						<spring:bind path="criticalDto.cpuMinor">					
							<%-- <input type="text" style="height: 20px; width: 150px" name="cpuMinor"  maxlength="20" value="70"> --%>
							<select name="cpuMinor" style="height: 20px; width: 150px">
								<option value="90">90</option>
								<option value="80">80</option>
								<option value="70">70</option>
								<option value="60">60</option>
								<option value="50" selected="selected">50</option>
								<option value="40">40</option>
								<option value="30">30</option>
								<option value="20">20</option>
								<option value="10">10</option>
								<option value="0">0</option>
							</select>
						</spring:bind>
					</td>
				</tr>
				<tr height="20px">
					<th style="width: 100px">PW:</th>
					<td>
						<spring:bind path="serverDto.svrPw">					
							<input type="password" style="height: 20px; width: 150px" name="svrPw" maxlength="20" value="freshman!$">
						</spring:bind>
					</td>
					<td></td>
					<td><hr></td>
					<td><hr></td>
				</tr>
				<tr height="20px">
					<th style="width: 100px">Serial_No:</th>
					<td>
						<spring:bind path="serverDto.serialNo">						
							<input type="text" style="height: 20px; width: 150px" id="serialNo" name="serialNo" maxlength="20" value="ML20150304">
						</spring:bind>
					</td>
					<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
					<th style="color: red; width: 100px">MEM Critical:</th>
					<td>	
						<spring:bind path="criticalDto.memoryCritical">					
							<%-- <input type="text" style="height: 20px; width: 150px" name="memoryCritical" maxlength="20" value="90"> --%>
							<select name="memoryCritical" id="memoryCritical" style="height: 20px; width: 150px">
								<option value="90" selected="selected">90</option>
								<option value="80">80</option>
								<option value="70">70</option>
								<option value="60">60</option>
								<option value="50">50</option>
								<option value="40">40</option>
								<option value="30">30</option>
								<option value="20">20</option>
								<option value="10">10</option>
								<option value="0">0</option>
							</select>
						</spring:bind>
					</td>
				</tr>
				<tr height="20px">
					<th style="width: 100px">IP_Address:</th>
					<td>
						<spring:bind path="serverDto.ip">					
							<input type="text" style="height: 20px; width: 150px" name="ip" maxlength="20" value="129.0.3.4">
						</spring:bind>
					</td>
					<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
					<th style="color: yellow; width: 100px">MEM Major:</th>
					<td>	
						<spring:bind path="criticalDto.memoryMajor">					
							<%-- <input type="text" style="height: 20px; width: 150px" name="memoryMajor"  maxlength="20" value="70"> --%>
							<select name="memoryMajor" style="height: 20px; width: 150px">
								<option value="90">90</option>
								<option value="80">80</option>
								<option value="70">70</option>
								<option value="60" selected="selected">60</option>
								<option value="50">50</option>
								<option value="40">40</option>
								<option value="30">30</option>
								<option value="20">20</option>
								<option value="10">10</option>
								<option value="0">0</option>
							</select>
						</spring:bind>
					</td>
				</tr>
				<tr height="20px">
					<th style="width: 100px">건물명:</th>
					<td>		
						<spring:bind path="serverDto.building">			
							<input type="text" style="height: 20px; width: 150px" name="building" maxlength="20" value="mediaLog">
						</spring:bind>
					</td>
					<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
					<th style="color: lime; width: 100px">MEM Minor:</th>
					<td>	
						<spring:bind path="criticalDto.memoryMinor">					
							<%-- <input type="text" style="height: 20px; width: 150px" name="memoryMinor"  maxlength="20" value="50"> --%>
							<select name="memoryMinor" style="height: 20px; width: 150px">
								<option value="90">90</option>
								<option value="80">80</option>
								<option value="70">70</option>
								<option value="60">60</option>
								<option value="50">50</option>
								<option value="40">40</option>
								<option value="30" selected="selected">30</option>
								<option value="20">20</option>
								<option value="10">10</option>
								<option value="0">0</option>
							</select>
						</spring:bind>
					</td>
				</tr>
				<tr height="20px">
					<th style="width: 100px">층번호:</th>
					<td>
						<spring:bind path="serverDto.floor">					
							<input type="text" style="height: 20px; width: 150px" name="floor" maxlength="20" value="9">
						</spring:bind>
					</td>
					<td></td>
					<td><hr></td>
					<td><hr></td>
				</tr>
				<tr height="20px">
					<th style="width: 100px">랙번호:</th>
					<td>
						<spring:bind path="serverDto.rack">					
							<input type="text" style="height: 20px; width: 150px" name="rack" maxlength="20" value="15">
						</spring:bind>
					</td>
					<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
					<th style="color: red; width: 100px">HDD Critical:</th>
					<td>
						<spring:bind path="criticalDto.hddCritical">						
							<%-- <input type="text" style="height: 20px; width: 150px" name="hddCritical" maxlength="20" value="90"> --%>
							<select name="hddCritical" id="hddCritical" style="height: 20px; width: 150px">
								<option value="90" selected="selected">90</option>
								<option value="80">80</option>
								<option value="70">70</option>
								<option value="60">60</option>
								<option value="50">50</option>
								<option value="40">40</option>
								<option value="30">30</option>
								<option value="20">20</option>
								<option value="10">10</option>
								<option value="0">0</option>
							</select>
						</spring:bind>
					</td>
				</tr>
				<tr height="20px">
					<th style="width: 100px">종류:</th>
					<td>
						<spring:bind path="serverDto.type">					
							<input type="text" style="height: 20px; width: 150px" name="type" maxlength="20" value="Server">
						</spring:bind>
					</td>
					<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
					<th style="color: yellow; width: 100px">HDD Major:</th>
					<td>	
						<spring:bind path="criticalDto.hddMajor">					
							<%-- <input type="text" style="height: 20px; width: 150px" name="hddMajor" maxlength="20" value="60"> --%>
							<select name="hddMajor" style="height: 20px; width: 150px">
								<option value="90">90</option>
								<option value="80">80</option>
								<option value="70">70</option>
								<option value="60">60</option>
								<option value="50" selected="selected">50</option>
								<option value="40">40</option>
								<option value="30">30</option>
								<option value="20">20</option>
								<option value="10">10</option>
								<option value="0">0</option>
							</select>
						</spring:bind>
					</td>
				</tr>
				<tr height="20px">
					<th style="width: 100px">모델명:</th>
					<td>
						<spring:bind path="serverDto.modelName">					
							<input type="text" style="height: 20px; width: 150px" name="modelName" maxlength="20" value="Intel">
						</spring:bind>
					</td>
					<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
					<th style="color: lime; width: 100px">HDD Minor:</th>
					<td>	
						<spring:bind path="criticalDto.hddMinor">					
							<%-- <input type="text" style="height: 20px; width: 150px" name="hddMinor"  maxlength="20" value="30"> --%>
							<select name="hddMinor" style="height: 20px; width: 150px">
								<option value="90">90</option>
								<option value="80">80</option>
								<option value="70">70</option>
								<option value="60">60</option>
								<option value="50">50</option>
								<option value="40">40</option>
								<option value="30">30</option>
								<option value="20">20</option>
								<option value="10" selected="selected">10</option>
								<option value="0">0</option>
							</select>
						</spring:bind>
					</td>
				</tr>
				<tr height="20px">
					<th style="width: 100px">CPU 수:</th>
					<td>
						<spring:bind path="serverDto.cpuNum">					
							<input type="text" style="height: 20px; width: 150px" name="cpuNum" maxlength="20" value="50">
						</spring:bind>
					</td>
					<td></td>
					<td></td>
					<td></td>
				</tr>
				<tr height="20px">
					<th style="width: 100px">Total MEM(GB):</th>
					<td>
						<spring:bind path="serverDto.totalMemory">					
							<input type="text" style="height: 20px; width: 150px" name="totalMemory" maxlength="20" value="100">
						</spring:bind>
					</td>
					<td></td>
					<td></td>
					<td></td>
				</tr>
				<tr height="20px">
					<th style="width: 100px">DISK 수:</th>
					<td>
						<spring:bind path="serverDto.diskNum">					
							<input type="text" style="height: 20px; width: 150px" name="diskNum" maxlength="20" value="70">
						</spring:bind>
					</td>
					<td></td>
					<td></td>
					<td></td>
				</tr>
				<tr height="20px">
					<th style="width: 100px">등록자 ID:</th>
					<td>	
						<spring:bind path="serverDto.usrId">				
							<input type="text" style="height: 20px; width: 150px" name="usrId" maxlength="20" value="jeonginhwa">
						</spring:bind>
					</td>
					<td></td>
					<td></td>
					<td></td>
				</tr>
				<tr height="20px">
					<th style="width: 100px">표시 여부:</th>
					<td>
						<spring:bind path="serverDto.visible">					
							<%--<input type="text" style="height: 20px; width: 150px" name="visible" maxlength="20" value="Y"> --%>
							<select name="visible" style="height: 20px; width: 150px">
								<option value="Y">Y</option>
								<option value="N">N</option>
							</select>
						</spring:bind>
					</td>
					<td></td>
					<td></td>
					<td></td>
				</tr>
			</table>
			<input type="button" id="saveBtn" style="width: 50px; height: 30px;" value="저장">
			<%-- <input type="submit" style="width: 70px; height: 50px;" value="저장"> --%>
			<%-- <input type="reset" style="width: 70px; height: 50px;" value="취소"> --%>			
			<a href="/am/cancel"><input type="button" id="resetBtn" style="width: 50px; height: 30px;" value="취소"></a>
 		</form>
 		
	</div>		
	
	<div></div>
</body>
</html>